package com.droid.lib.controls.demo.view;

import com.droid.lib.controls.demo.R;
import com.droid.lib.controls.demo.util.MResource;
import com.droid.lib.controls.widget.Lock9View;
import com.droid.lib.controls.widget.Lock9View.CallBack;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;

/**
 * Lock9View
 * 
 * @author Administrator
 *
 */
public class Lock9Fragment extends Fragment {
	private Context mContext;
	private Lock9View mLock9View;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		mContext = getActivity();
		LinearLayout layout = new LinearLayout(mContext);
		LinearLayout.LayoutParams lock9Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		lock9Params.setMargins(MResource.getDip(mContext, 24), MResource.getDip(mContext, 24),
				MResource.getDip(mContext, 24), MResource.getDip(mContext, 24));
		mLock9View = new Lock9View(mContext, R.drawable.img_lock9_no, R.drawable.img_lock9_pre, R.color.color_orange);
		layout.addView(mLock9View,lock9Params);
		LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		layout.setLayoutParams(layoutParams);
		mLock9View.setCallBack(new CallBack() {

			@Override
			public void onFinish(String password) {
				Toast.makeText(mContext, password, Toast.LENGTH_SHORT).show();
			}

		});
		return layout;
	}
}
